<template>
  <div id="app">
    <el-row >
      <el-col :span="5"><div class="grid-content bg-purple-dark">
        <el-image
          style="height: 60px;width: 240px"
          src="http://qtuhxsikh.hd-bkt.clouddn.com/logon1.png"
          fit="fit"></el-image>
      </div></el-col>
      <el-col :span="19"><div class="grid-content bg-purple-dark" >
        <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect" >

          <el-submenu index="1">
            <template slot="title" ><font style="font-size: 24px">书籍管理</font></template>
            <el-menu-item index="1-1">分类书籍</el-menu-item>
            <el-menu-item index="1-2">书单管理</el-menu-item>
            <el-menu-item index="1-3">文章审核</el-menu-item>
            <el-submenu index="1-4">
              <template slot="title">选项4</template>
              <el-menu-item index="1-4-1">选项1</el-menu-item>
              <el-menu-item index="1-4-2">选项2</el-menu-item>
              <el-menu-item index="1-4-3">选项3</el-menu-item>
            </el-submenu>
          </el-submenu>

          <el-menu-item index="2" style="font-size: 24px">读者管理</el-menu-item>

          <el-menu-item index="3" style="font-size: 24px">作者管理</el-menu-item>
          <el-menu-item index="4" style="font-size: 24px">消息中心</el-menu-item>
          <el-menu-item index="5" style="text-align: right ;margin-left: 300px">
            <font style="font-size: 20px; ">{{username}}</font>
            <font style="font-size: 20px; " > /</font>
            <font style="font-size: 20px; " @click="exitLogin">退出</font>
          </el-menu-item>

        </el-menu>

      </div></el-col>
    </el-row>

    <router-view/>
  </div>
</template>

<script>
  import axios from 'axios';
  import vueCookie from 'vue-cookie';
export default {
  name: 'App',
  data(){
    return{
      username:'',
      activeIndex: '1',
      activeIndex2: '1'
    }
  },
  methods:{
    verifyLogin(){
      axios.post('http://localhost:8888/manage/findManager').then(res=>{
          if(res.data.code==0){
            this.username=res.data.data;
          }else{

          }
      })
    },
    exitLogin(){
      vueCookie.delete("token");
    },
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
      this.$router.push(key);
    }
  },
  mounted() {
    this.verifyLogin();
  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 0px;
}
</style>
